package servlet;

import service.UseInfoService;
import utils.MyBatisUtil;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;

import static java.lang.Thread.sleep;

@WebServlet(name = "DeleteUseInfoServlet", value = "/DeleteUseInfoServlet")
public class DeleteUseInfoServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request, response);

    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        UseInfoService uis = new UseInfoService();
        int i = uis.deleteUser(Integer.valueOf(request.getParameter("id")));
        if(i==1) {
            response.getWriter().println("success");
        }
        else {
            response.getWriter().println("failed");
        }
        MyBatisUtil.closeSession();
        request.getRequestDispatcher("/SelectAllServlet").forward(request, response);
    }
}
